package com.software.graduationproject.commons.enums;

import com.v2coding.validate.BaseEnum;

/**
 * CommonFlagType : 是否标志
 * ---------------------------------------------------------------------------------------------------------------------
 */
public enum CommonFlagType implements BaseEnum<CommonFlagType, Integer> {

    Y("是", 1),

    N("否", 0),

    ERROR("数据错误", -1),

    ;

    private final String  label;
    private final Integer value;

    CommonFlagType(String label, Integer value) {
        this.label = label;
        this.value = value;
    }

    @Override
    public Integer getValue() {
        return this.value;
    }

    @Override
    public String getLabel() {
        return this.label;
    }

    @Override
    public CommonFlagType getEnum(Integer value) {
        if (null == value) {
            return ERROR;
        }
        for (CommonFlagType e : values()) {
            if (e.value.equals(value)) {
                return e;
            }
        }
        return ERROR;
    }

}
